package com.itcast.listener;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Configuration;

import java.util.Map;


@Configuration
public class DirectListener {
//    @RabbitListener(queues = "direct.Queue")
//    public void process(Map testMessage) {
//        System.out.println("DirectReceiver消费者收到消息  : " + testMessage.toString());
//    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "direct.queue1",durable = "false"),
            exchange = @Exchange(name = "direct.exchange1",durable = "false",
            type = ExchangeTypes.DIRECT),
            key = {"red","blue"}
    ))
    public void directListener1(String msg) {
        System.out.println("DirectReceiver消费者1收到消息  : " +msg);
    }
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "direct.queue2",durable = "false"),
            exchange = @Exchange(name = "direct.exchange1",durable = "false",
                    type = ExchangeTypes.DIRECT),
            key = {"red","yellow"}
    ))
    public void directListener2(String msg) {
        System.out.println("DirectReceiver消费者2收到消息  : " +msg);
    }
}
